<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the warnings and errors</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="datetimeimmutable.createfrommutable.html">« DateTimeImmutable::createFromMutable</a></li>
      <li style="float: right;"><a href="datetimeimmutable.modify.html">DateTimeImmutable::modify »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.datetimeimmutable.html">DateTimeImmutable</a></li>
    <li>Returns the warnings and errors</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="datetimeimmutable.getlasterrors" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTimeImmutable::getLastErrors</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DateTimeImmutable::getLastErrors</span> &mdash; <span class="dc-title">Returns the warnings and errors</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetimeimmutable.getlasterrors-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>DateTimeImmutable::getLastErrors</strong></span>(): <span class="type"><span class="type">array</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Returns an array of warnings and errors found while parsing
   a date/time string.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-datetimeimmutable.getlasterrors-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetimeimmutable.getlasterrors-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns array containing info about warnings and errors, or <strong><code>false</code></strong> if there
   are neither warnings nor errors.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-datetimeimmutable.getlasterrors-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2017">
   <p><strong>示例 #1 <span class="function"><strong>DateTimeImmutable::getLastErrors()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$date&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">(</span><span style="color: #DD0000">'asdfasdf'</span><span style="color: #007700">);<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;For&nbsp;demonstration&nbsp;purposes&nbsp;only...<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">getLastErrors</span><span style="color: #007700">());<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;The&nbsp;real&nbsp;object-oriented&nbsp;way&nbsp;to&nbsp;do&nbsp;this&nbsp;is<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;echo&nbsp;$e-&gt;getMessage();<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
   [warning_count] =&gt; 1
   [warnings] =&gt; Array
       (
           [6] =&gt; Double timezone specification
       )

   [error_count] =&gt; 1
   [errors] =&gt; Array
       (
           [0] =&gt; The timezone could not be found in the database
       )

)
</pre></div>
   </div>
   <div class="example-contents"><p>
    The indexes 6, and 0 in the example output refer to the character index in the string where the error occurred.
   </p></div>
  </div>
 </div>



</div></div></div></body></html>